#include"ScriptEntry.h" 
ScriptEntry::ScriptEntry(const QString &sql, const QString &comment, QWidget *parent):QWidget(parent){
	m_script = 0;
	m_sql = sql;
	
    init(comment);
}

ScriptEntry::ScriptEntry(const QString &sql, const QString &comment, ScriptEntryRaw *script, QWidget *parent):QWidget(parent){
    init(comment);
    m_sql = sql;
	m_script = script;
	m_buttonEdit = new QPushButton("Edit", this);
	m_layout->insertWidget(1, m_buttonEdit);
	connect(m_buttonEdit, SIGNAL(clicked()), this, SLOT(slotEdit()));
}

ScriptEntry::~ScriptEntry(){

}

void ScriptEntry::init(const QString &comment){
    m_layout = new QHBoxLayout(this);
    setLayout(m_layout);

    m_label = new QLabel(comment, this);
    m_layout->addWidget(m_label);

    m_buttonEdit = 0;

    m_buttonDelete = new QPushButton("Delete", this);
    m_layout->addWidget(m_buttonDelete);
    connect(m_buttonDelete, SIGNAL(clicked()), this, SLOT(slotDelete()));
}

void ScriptEntry::slotDelete(){
	emit deleteMe();
}

void ScriptEntry::slotEdit(){
	emit editMe();
}
